﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false" namespace="PetShop.Domain.Model"  assembly="PetShop">

	<class name="Order" table="Orders" >

		<id name="OrderId" column="OrderId" access="field.pascalcase-underscore" type="System.Int32" >
			<generator class="native"/>
		</id>
		<property name="OrderDate" column="OrderDate" access="field.pascalcase-underscore" not-null="true" type="System.DateTime"  insert="true" update="true"/>
		<many-to-one name="User"  access="field.pascalcase-underscore" not-null="true" outer-join="auto" insert="true" update="true">
			<column name="UserId"/>
		</many-to-one>
		<property name="OrderTotal" column="TotalPrice" access="field.pascalcase-underscore" not-null="true" type="System.Decimal"  insert="true" update="true"/>
	
		<component name="BillingAddress"  class="AddressInfo">
			<property name="Address1" column="BillAddr1" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="Address2" column="BillAddr2" access="field.pascalcase-underscore" not-null="false" type="System.String"  length="80" insert="true" update="true"/>
			<property name="City" column="BillCity" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="Country" column="BillCountry" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="20" insert="true" update="true"/>
			<property name="State" column="BillState" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="FirstName" column="BillToFirstName" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="LastName" column="BillToLastName" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="Zip" column="BillZip" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="20" insert="true" update="true"/>
	   </component>
		
		<component name="CreditCard"  class="CreditCardInfo">
			<property name="CardType" column="CardType" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="40" insert="true" update="true"/>
			<property name="CreditCard" column="CreditCard" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="20" insert="true" update="true"/>
			<property name="ExprDate" column="ExprDate" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="7" insert="true" update="true"/>
		</component>
		
		<component name="ShippingAddress"  class="AddressInfo">
			<property name="Address1" column="ShipAddr1" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="Address2" column="ShipAddr2" access="field.pascalcase-underscore" not-null="false" type="System.String"  length="80" insert="true" update="true"/>
			<property name="City" column="ShipCity" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="Country" column="ShipCountry" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="20" insert="true" update="true"/>
			<property name="State" column="ShipState" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="FirstName" column="ShipToFirstName" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="LastName" column="ShipToLastName" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="80" insert="true" update="true"/>
			<property name="Zip" column="ShipZip" access="field.pascalcase-underscore" not-null="true" type="System.String"  length="20" insert="true" update="true"/>
		</component>

		<bag name="LineItems" cascade="all-delete-orphan"  lazy="true" access="field.pascalcase-underscore" inverse="true">
			<key>
				<column name="OrderId" not-null="true"/>
			</key>
			
			<one-to-many class="LineItemEntity" />
		</bag>

	</class>
</hibernate-mapping>

